const { exec } = require('child_process');

// 在这里添加或修改学生数据
const students = [
    {
        ro_student_name: "丁真",
        ro_classtime: "4.00",
        studentId: 220,
        mobile: "15687894653",
        grade: "初二",
        examTotalScore: "",
        tutored: 0,
        expectStartTime: "",
        studentDescription: "",
        courseSuggestion: "",
        reviewSuggestion: "",
        examType: "",
        examScore: ""
    }
];

const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1IjoiMzkwMzY3OmFnZW5jeTE3NzJlMDVmNzFlMjRiNWE5MTVlYzcyMTI0ZDZlYWI3In0.0mdmSkSYrLhQ020Wi9W8P2orflanMimV6oQ4613JV48';

setInterval(() => {
    students.forEach(student => {
        const dataRaw = JSON.stringify(student);

        // 注意：在命令行中直接使用时，需要确保 dataRaw 中的双引号被正确转义。
        // 在 Node.js 的 exec 中，我们传递一个完整的字符串，Shell 会处理它，但为了安全和清晰，我们用单引号包裹 JSON 字符串。
        const command = `curl 'https://qingqiu-api.gsudev.cn/api/english/japi/signup-receipt/add' \
        -H 'accept: */*' \
        -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' \
        -H 'ajax: json' \
        -H 'content-type: application/json' \
        -H 'dnt: 1' \
        -H 'origin: http://qingqiu-yy.gsudev.cn' \
        -H 'priority: u=1, i' \
        -H 'referer: http://qingqiu-yy.gsudev.cn/' \
        -H 'rtp: 1' \
        -H 'sec-ch-ua: "Chromium";v="136", "Microsoft Edge";v="136", "Not.A/Brand";v="99"' \
        -H 'sec-ch-ua-mobile: ?0' \
        -H 'sec-ch-ua-platform: "macOS"' \
        -H 'sec-fetch-dest: empty' \
        -H 'sec-fetch-mode: cors' \
        -H 'sec-fetch-site: cross-site' \
        -H 'token: ${token}' \
        -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0' \
        --data-raw '${dataRaw}'`;

        exec(command, (error, stdout, stderr) => {
            console.log(`正在为 ${student.ro_student_name} 创建... `);
            if (error) {
                console.error(`执行出错 for ${student.ro_student_name}: `, error);
                return;
            }
            if (stderr) {
                console.error(`请求标准错误 for ${student.ro_student_name}: `, stderr);
            }
            console.log(`${student.ro_student_name} 的响应: `, stdout);
            console.log('--------------------------------------------------');
        });
    });
}, 1000);


